package yz.mr.OutPut;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class MyOutputFormat extends FileOutputFormat {
    /**
     *该方式需要返回一个RecordWriter的对象
     * RecordWriter有两个抽象方法：
     *      write：可以接受Map端或者Reduce端写出来的KV数据，并且可以在该方法中定义写出数据的逻辑
     *
     *      close：可以用来关闭输出流
     */
    @Override
    public RecordWriter getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {
        Configuration configuration = job.getConfiguration();
        return new MyRecordWriter(configuration);
    }
}
